$(function(){
    $('.btnLogin').on('click',function(){
        let email=$('#email').val();
        let password=$('#password').val();
        //验证邮箱
        if(!/\w+[@]\w+[.]\w+/.test(email)){
            $('.aletWrong span').text('请输入正确的邮箱')
            $('.aletWrong').fadeIn(1000).fadeOut(1000);
            return;
        }
        //验证密码
        if(password.length<6||password.length>16){
            $('.aletWrong span').text('请输入6-16位的密码')
            $('.aletWrong').fadeIn(1000).fadeOut(1000);
            return;
        }
        $.ajax({
            url:"/userLogin",
            type:"post",
            data:$('form').serialize(),
            success(res){
                console.log(res);
                if(res.code!=='200'){
                    $('.aletWrong span').text(res.msg)
                    $('.aletWrong').fadeIn(1000).fadeOut(1000);
                    return;
                }else{
                    location.href="/admin/index";
                }
            }
        })
    })
})